




/*
'===============================================================================
'  HNG.Portal.BL.TblLienHeManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblLienHeManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_LangId="LangId";
				
				public const String Field_TenNguoiGui="TenNguoiGui";
				
				public const String Field_DienThoai="DienThoai";
				
				public const String Field_Email="Email";
				
				public const String Field_GuiDen="GuiDen";
				
				public const String Field_TieuDe="TieuDe";
				
				public const String Field_MoTa="MoTa";
				
				public const String Field_DanhDau="DanhDau";
				
				public const String Field_NgayGui="NgayGui";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblLienHeManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_LangId,typeof(string));
			
						
			
			dt.Columns.Add(Field_TenNguoiGui,typeof(string));
			
						
			
			dt.Columns.Add(Field_DienThoai,typeof(string));
			
						
			
			dt.Columns.Add(Field_Email,typeof(string));
			
						
			
			dt.Columns.Add(Field_GuiDen,typeof(string));
			
						
			
			dt.Columns.Add(Field_TieuDe,typeof(string));
			
						
			
			dt.Columns.Add(Field_MoTa,typeof(string));
			
						
			
			dt.Columns.Add(Field_DanhDau,typeof(bool));
			
						
			
			dt.Columns.Add(Field_NgayGui,typeof(DateTime));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblLienHeEntity Convert_Entity(TblLienHeEntity _TblLienHeEntity,TblLienHeEntity _TblLienHeEntity_XML)
		{	
			
				
			_TblLienHeEntity.Id= _TblLienHeEntity_XML.Id;
				
			_TblLienHeEntity.LangId= _TblLienHeEntity_XML.LangId;
				
			_TblLienHeEntity.TenNguoiGui= _TblLienHeEntity_XML.TenNguoiGui;
				
			_TblLienHeEntity.DienThoai= _TblLienHeEntity_XML.DienThoai;
				
			_TblLienHeEntity.Email= _TblLienHeEntity_XML.Email;
				
			_TblLienHeEntity.GuiDen= _TblLienHeEntity_XML.GuiDen;
				
			_TblLienHeEntity.TieuDe= _TblLienHeEntity_XML.TieuDe;
				
			_TblLienHeEntity.MoTa= _TblLienHeEntity_XML.MoTa;
				
			_TblLienHeEntity.DanhDau= _TblLienHeEntity_XML.DanhDau;
				
			_TblLienHeEntity.NgayGui= _TblLienHeEntity_XML.NgayGui;
				
			_TblLienHeEntity.TrangThai= _TblLienHeEntity_XML.TrangThai;
				
			
			return _TblLienHeEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblLienHeEntity Insert(TblLienHeEntity TblLienHeEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblLienHeEntity, true);
			}
			return TblLienHeEntity;
		}

		
		public TblLienHeEntity Insert(int Id, string LangId, string TenNguoiGui, string DienThoai, string Email, string GuiDen, string TieuDe, string MoTa, bool DanhDau, DateTime NgayGui, bool TrangThai)
		{
			TblLienHeEntity _TblLienHeEntity = new TblLienHeEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblLienHeEntity.Id = Id;
				_TblLienHeEntity.LangId = LangId;
				_TblLienHeEntity.TenNguoiGui = TenNguoiGui;
				_TblLienHeEntity.DienThoai = DienThoai;
				_TblLienHeEntity.Email = Email;
				_TblLienHeEntity.GuiDen = GuiDen;
				_TblLienHeEntity.TieuDe = TieuDe;
				_TblLienHeEntity.MoTa = MoTa;
				_TblLienHeEntity.DanhDau = DanhDau;
				_TblLienHeEntity.NgayGui = NgayGui;
				_TblLienHeEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblLienHeEntity, true);
			}
			return _TblLienHeEntity;
		}

		public TblLienHeEntity Insert(string LangId, string TenNguoiGui, string DienThoai, string Email, string GuiDen, string TieuDe, string MoTa, bool DanhDau, DateTime NgayGui, bool TrangThai)
		{
			TblLienHeEntity _TblLienHeEntity = new TblLienHeEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblLienHeEntity.LangId = LangId;
				_TblLienHeEntity.TenNguoiGui = TenNguoiGui;
				_TblLienHeEntity.DienThoai = DienThoai;
				_TblLienHeEntity.Email = Email;
				_TblLienHeEntity.GuiDen = GuiDen;
				_TblLienHeEntity.TieuDe = TieuDe;
				_TblLienHeEntity.MoTa = MoTa;
				_TblLienHeEntity.DanhDau = DanhDau;
				_TblLienHeEntity.NgayGui = NgayGui;
				_TblLienHeEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblLienHeEntity, true);
			}
			return _TblLienHeEntity;
		}

		public bool Update(TblLienHeEntity _TblLienHeEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblLienHeFields.Id == _TblLienHeEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblLienHeEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblLienHeEntity _TblLienHeEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblLienHeEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string LangId, string TenNguoiGui, string DienThoai, string Email, string GuiDen, string TieuDe, string MoTa, bool DanhDau, DateTime NgayGui, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblLienHeEntity _TblLienHeEntity = new TblLienHeEntity(Id);
				if (adapter.FetchEntity(_TblLienHeEntity))
				{
				
					_TblLienHeEntity.LangId = LangId;
					_TblLienHeEntity.TenNguoiGui = TenNguoiGui;
					_TblLienHeEntity.DienThoai = DienThoai;
					_TblLienHeEntity.Email = Email;
					_TblLienHeEntity.GuiDen = GuiDen;
					_TblLienHeEntity.TieuDe = TieuDe;
					_TblLienHeEntity.MoTa = MoTa;
					_TblLienHeEntity.DanhDau = DanhDau;
					_TblLienHeEntity.NgayGui = NgayGui;
					_TblLienHeEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblLienHeEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblLienHeEntity _TblLienHeEntity = new TblLienHeEntity(Id);
				if (adapter.FetchEntity(_TblLienHeEntity))
				{
					adapter.DeleteEntity(_TblLienHeEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblLienHeEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByLangId(string LangId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenNguoiGui(string TenNguoiGui)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TenNguoiGui == TenNguoiGui);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDienThoai(string DienThoai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.DienThoai == DienThoai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByEmail(string Email)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.Email == Email);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByGuiDen(string GuiDen)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.GuiDen == GuiDen);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTieuDe(string TieuDe)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TieuDe == TieuDe);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMoTa(string MoTa)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDanhDau(bool DanhDau)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.DanhDau == DanhDau);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByNgayGui(DateTime NgayGui)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.NgayGui == NgayGui);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblLienHeEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblLienHeEntity SelectOne(int Id)
		{
			TblLienHeEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblLienHeEntity _TblLienHeEntity = new TblLienHeEntity(Id);
				if (adapter.FetchEntity(_TblLienHeEntity))
				{
					toReturn = _TblLienHeEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblLienHeCollection = new EntityCollection( new TblLienHeEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, null, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByLangId(string LangId)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByLangIdRDT(string LangId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenNguoiGui(string TenNguoiGui)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TenNguoiGui == TenNguoiGui);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenNguoiGuiRDT(string TenNguoiGui)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TenNguoiGui == TenNguoiGui);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDienThoai(string DienThoai)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.DienThoai == DienThoai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDienThoaiRDT(string DienThoai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.DienThoai == DienThoai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByEmail(string Email)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.Email == Email);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByEmailRDT(string Email)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.Email == Email);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByGuiDen(string GuiDen)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.GuiDen == GuiDen);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByGuiDenRDT(string GuiDen)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.GuiDen == GuiDen);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTieuDe(string TieuDe)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TieuDe == TieuDe);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTieuDeRDT(string TieuDe)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TieuDe == TieuDe);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMoTa(string MoTa)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMoTaRDT(string MoTa)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDanhDau(bool DanhDau)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.DanhDau == DanhDau);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDanhDauRDT(bool DanhDau)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.DanhDau == DanhDau);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByNgayGui(DateTime NgayGui)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.NgayGui == NgayGui);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByNgayGuiRDT(DateTime NgayGui)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.NgayGui == NgayGui);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblLienHeCollection, filter, 0, null);
			}
			return _TblLienHeCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblLienHeCollection = new EntityCollection(new TblLienHeEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblLienHeFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblLienHeCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
